<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="../../../assets/docs.css" rel="stylesheet" type="text/css" media="screen" />
<title>MooTools 1.3 Documentation - Element/Elements.From</title>
</head>

<body>
  <div class="doc">
    <div class="methods">
      <h4 class="menu-item"><a href="#Elements">Elements</a></h4>
      <div class="menu-item"><a href="#Elements:Elements-from">Elements.from</a></div>
    </div>
    <div class="l-border r-border span-15 content">
      <h1 id="Elements"><a href="#Elements">Type: Elements</a></h1>
      <p class="description">Extends the <a href="../../../docs/core/Element/Element.html#Elements">Elements</a> object to add a function that returns a collection of elements from a string of html.</p>
      <h2 id="Elements:Elements-from"><a href="#Elements:Elements-from">Function: Elements.from</a></h2>
      <p class="description">Returns a collection of elements from a string of html.</p>
      <h3>Syntax</h3>
      <pre class="javascript">Elements.<span class="me1">from</span><span class="br0">(</span>str, excludeScripts<span class="br0">)</span>;
</pre>
      <h3>Arguments</h3>
      <ol>
        <li>str - (<em>string</em>) an html string.</li>
        <li>excludeScripts - (<em>boolean</em>) if <em>true</em>, the default, scripts are not included in the element collection returned.</li>
      </ol>
      <h3>Example</h3>
      <pre class="javascript"><span class="kw2">var</span> els = Elements.<span class="me1">from</span><span class="br0">(</span><span class="st0">"&lt;p&gt;this is a &lt;i&gt;string&lt;/i&gt; of &lt;b&gt;HTML&lt;/b&gt;.&lt;/p&gt;&lt;p&gt;It has two paragraphs.&lt;/p&gt;"</span><span class="br0">)</span>;
els.<span class="me1">each</span><span class="br0">(</span><span class="kw2">function</span><span class="br0">(</span>paragraph<span class="br0">)</span><span class="br0">{</span>

    console.<span class="me1">log</span><span class="br0">(</span>paragraph<span class="br0">)</span>; <span class="co1">//logs each paragraph</span>
<span class="br0">}</span><span class="br0">)</span>;
els.<span class="me1">inject</span><span class="br0">(</span>document.<span class="me1">body</span><span class="br0">)</span>; <span class="co1">//injects both paragraphs into the document body</span>

</pre>
      <h3>Returns</h3>
      <ul>
        <li>(<em>array</em>) an array of elements (i.e. a collection) - an instance of <a href="../../../docs/core/Element/Element.html#Elements">Elements</a>.</li>
      </ul>
    </div>
  </div>
<script type="text/javascript" src="../../../assets/mootools-core-1.3.js"></script>
<script type="text/javascript" src="../../../assets/mootools-more-smoothscroll.js"></script>
<script type="text/javascript" src="../../../assets/doc-assist.js"></script>
</body>
</html>
